package model.zhuangtai;

/**
 * @author 乔巴
 * 2022-11-08 14:49
 */
public class LockedState extends State {

    LockedState(Player player) {
        super(player);
        player.setPlaying(false);
    }

    @Override
    public String onLock() {
        // 逻辑一
//        if (player.isPlaying()) {
//            player.changeState(new ReadyState(player));
//            return "Stop playing";
//        } else {
//            return "Locked...";
//        }
        // 逻辑二
        if (player.isPlaying()) {
            player.changeState(new ReadyState(player));
            return "Stop playing";
        } else {
            return "Locked...";
        }
    }

    @Override
    public String onPlay() {
        String action = player.startPlayback();
        player.changeState(new PlayingState(player));
        return action;
    }

    @Override
    public String onNext() {
        return player.nextTrack();
    }

    @Override
    public String onPrevious() {
        return player.previousTrack();
    }
}
